package io.kiki.sba.registry.common.model.metaserver;

import io.kiki.sba.registry.util.StringUtil;
import lombok.Getter;

import java.io.Serializable;

@Getter
public class RemoteDatumClearEvent implements Serializable {

    private final String remoteDataCenter;

    private final DatumType datumType;

    private final String dataInfoId;

    private final String group;

    private RemoteDatumClearEvent(String remoteDataCenter, DatumType datumType, String dataInfoId, String group) {
        this.remoteDataCenter = remoteDataCenter;
        this.datumType = datumType;
        this.dataInfoId = dataInfoId;
        this.group = group;
    }

    public static RemoteDatumClearEvent dataInfoIdEvent(String remoteDataCenter, String dataInfoId) {
        StringUtil.checkNotBlank(remoteDataCenter, "remoteDataCenter");
        StringUtil.checkNotBlank(dataInfoId, "dataInfoId");
        return new RemoteDatumClearEvent(remoteDataCenter, DatumType.data_info_id, dataInfoId, null);
    }

    public static RemoteDatumClearEvent groupEvent(String remoteDataCenter, String group) {
        StringUtil.checkNotBlank(remoteDataCenter, "remoteDataCenter");
        StringUtil.checkNotBlank(group, "group");
        return new RemoteDatumClearEvent(remoteDataCenter, DatumType.group, null, group);
    }


    public enum DatumType {
        data_info_id, group, //data_info_id, group,
        ;
    }
}
